<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        .box1 {
            margin: 20px 50px;
            position: relative;
            width: 450px;
            height: 550px;
            background-color: skyblue;
        }
        
        img {
            width: 100%;
            height: 100%;
        }
        
        .box2 {
            display: none;
            position: absolute;
            top: 50%;
            left: 50%;
            transform: translate(-50%, -50%);
            width: 200px;
            height: 200px;
            background-color: rgba(243, 231, 152, 0.4);
        }
        
        .box3 {
            display: none;
            position: absolute;
            right: -600px;
            top: 0px;
            width: 550px;
            height: 650px;
            background-color: #fff;
            overflow: hidden;
        }
        
        .box4 {
            position: absolute;
            top: 0px;
            left: 0px;
            width: 100%;
            height: 100%;
            transform: scale(1.2);
        }
    </style>
</head>

<body>
    <div class="box1">
        <img src="images\rotate.jpg" alt="">
        <div class="box2"></div>
        <div class="box3">
            <img src="images\rotate.jpg" alt="" class="box4">
        </div>
    </div>
    <script>
        var box1 = document.querySelector('.box1');
        var box2 = document.querySelector('.box2');
        var box3 = document.querySelector('.box3');
        var box4 = document.querySelector('.box4');
        box1.addEventListener('mouseover', function() {
            box2.style.display = 'block';
            box3.style.display = 'block';
        })
        box1.addEventListener('mouseout', function() {
            box2.style.display = 'none';
            box3.style.display = 'none';
        })
        box1.addEventListener('mousemove', function(e) {
            var left = e.pageX - box1.offsetLeft;
            var top = e.pageY - box1.offsetTop;
            if (left <= 100) {
                left = 100;
            } else if (left >= 350) {
                left = 350;
            }
            if (top <= 100) {
                top = 100;
            } else if (top >= 450) {
                top = 450;
            }
            box2.style.left = left + 'px';
            box2.style.top = top + 'px';
            box4.style.left = -(left * 0.5) + 'px';
            box4.style.top = -(top * 0.5) + 'px';
        })
    </script>
</body>

</html>